package org.tru42.signal.model;

import java.lang.reflect.InvocationTargetException;

import org.tru42.signal.lang.ConnectException;
import org.tru42.signal.lang.ISink;

public class ConstantSignal extends AbstractSignal {

	private final String name;
	
	public ConstantSignal(Object owner, String name, Object value) {
		super(owner);
		this.name = name;
		setValue(value);
	}

	@Override
	public String getName() {
		return name;
	}

	@Override
	public Class<?>[] getTypes() {
		return new Class<?>[]{long.class, value[0].getClass()};
	}

	@Override
	public void trigger() throws IllegalArgumentException,
			IllegalAccessException, InvocationTargetException {
		setValue(value);
	}
	
	@Override
	public void connectSink(ISink sink) throws ConnectException {
		super.connectSink(sink);
		try {
			trigger();
		} catch (Exception e) {
		}
	}

}
